<%@page import="com.railway.files.model.*" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>

<html>

<head>
	<link rel="stylesheet" type="text/css" href="${ctx}/css/default.css" />
		<link rel="stylesheet" href="${ctx}/css/ztree.css" type="text/css">
		<link rel="stylesheet" href="${ctx}/css/zTreeStyle/zTreeStyle.css"	type="text/css">
		
		
		<link href="${ctx}/commons/upload/css/uploadify.css" rel="stylesheet" type="text/css" />
		
		
		<script type="text/javascript"
			src="${ctx}/scripts/jquery-1.4.2.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery.easyui.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/locale/easyui-lang-zh_CN.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery-1.4.4.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/commons/upload/js/swfobject.js"></script>
		<script type="text/javascript"
			src="${ctx}/commons/upload/js/jquery.uploadify.v2.1.4.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery.ztree.core-3.0.min.js"></script>
		<script type="text/javascript"
			src="${ctx}/scripts/jquery.ztree.excheck-3.0.min.js"></script>
	
	<script type="text/javascript"> 	
	function deleteUploadedFiles(){
	      jQuery('#fileupload').uploadifyClearQueue();
	      form1.uploadedfileid.value = "";
	      $('.files').empty();
        
	     /* if(form1.uploadedfileid.value == '') return;
		     $.get("${ctx}/files/Files/deleteByAjax.do?t="+Math.random(), {
                Action:"get","fileTypes":"ADDRESS",uploadedfileid:form1.uploadedfileid.value}, function (data, textStatus){	
   	              $('.files').empty();
         		  $('#filename').empty();
         		  form1.uploadedfileid.value = "";
         		
     
		   });	   */
	}
		    function openURL(urlstr,width,height){  
		    
      			 var url  = '${ctx}/files/FilesCategory/showCategoryTree.do'; 
          		 var returnVal = window.showModalDialog(url, window, "dialogWidth="+width+"px;dialogHeight="+height+"px;status:0;scroll:no");   
            	 form1.objId.value = returnVal[0]; 
           		 form1.catname.value = returnVal[1]; 
        	}   
	
	        $(document).ready(function() { 


	
	           
	        	
	            $("#fileupload").uploadify({
	           
	                 'allBytesLoaded':500 * 1024*1024,
	                /*注意前面需要书写path的代码*/ 
	                'uploader'       : '${ctx}/commons/upload/js/uploadify.swf', 
	                'script'         : '${ctx}/files/Files/upload.do', 
	                'cancelImg'      : '${ctx}/commons/upload/images/cancel.png', 
	                'queueID'        : 'fileQueue', //和存放队列的DIV的id一致 
	                'fileDataName'   : 'fileupload', //和以下input的name属性一致 
	                'auto'           : false, //是否自动开始 
	                'multi'          : false, //是否支持多文件上传 
	                'buttonText'     : '选择文件', //按钮上的文字 
	                'simUploadLimit' : 1, //一次同步上传的文件数目 
	                'sizeLimit'      : 4000* 1024 * 1024, //设置单个文件大小限制 
	              
	            onComplete: function (event, queueID, fileObj, response, data) { 
      			     var objs = eval("["+response+"]");	               
	                 form1.uploadedfileid.value = objs[0].uploadedfileid;            
	                
					$('<li></li>').appendTo('.files').text(objs[0].uploadedresult); 
	}, 
	       onError: function(event, queueID, fileObj) { 
	             alert("文件:" + fileObj.name + "上传失败"); 
	       }, 
	       onCancel: function(event, queueID, fileObj){ 
	       alert("取消了" + fileObj.name); 
	       } 
	       }); 


	
	        }); 
	        </script> 
	
	<script type="text/javascript"> 
	      
	function uploadifyUpload(){ 
 
	     if(form1.uploadedfileid.value  != null &&  form1.uploadedfileid.value != ""){
	                   alert("附件已添加!");
	                   return;
	     }
 
	   $('#fileupload').uploadifyUpload(); 
	} 
	</script> 
	
	
	<title><%=FilesColums.TABLE_ALIAS%>新增</title>
</head>
<body>
	<form id="form1" action="${ctx}/files/Files/save.do?fileTypes=SOFT" method="post">
	    
		<input type="submit" value="提交" />
		<input type="button" value="返回列表" onclick="window.location='${ctx}/files/Files/list.do?fileTypes=SOFT'"/>
		<input type="button" value="后退" onclick="history.back();"/>
		<input type="hidden" name="uploadedfileid"	value="${model.uploadedfileid}" />
		

		<table class="formTable">
			<input type="hidden" id="id" name="id" value="${model.id}"/>
			<tr>	
				<td class="tdLabel">
					<%=FilesColums.ALIAS_NAMES%>:
				</td>	
				<td>
					<input id="names" name="names" value="${model.names}" type="text"  class="easyui-validatebox"/>
				</td>
			</tr>	
			
			<tr>	
				<td class="tdLabel">
					<%=FilesColums.ALIAS_MEMO%>:
				</td>	
				<td>
					<input id="memo" name="memo" value="${model.memo}" type="text"  class="easyui-validatebox"/>
				</td>
			</tr>			
			<tr>	
				<td class="tdLabel">
					<%=FilesColums.ALIAS_CATEGORY%>:
				</td>	
				<td>		
				
				<input id="catname" name="catname" value="" type="text" readonly  class="easyui-validatebox" onclick="javascript:openURL('Dept',250,400)"/>
				<input  id="objId" name="objId" value="${model.objId}" type="hidden"  class="easyui-validatebox"/>
				</td>
			</tr>
		</table>
	</form>
	  <table>
	   <tr> 

	<td> 
	<input type="file" name="fileupload" id="fileupload" /> 
	<div id="fileQueue"></div> 
	<p> 
	<a href="javascript:;" onClick="javascript:uploadifyUpload()">开始上传</a>&nbsp; 
	<a href="javascript:jQuery('#fileupload').uploadifyClearQueue()">取消所有上传</a> 
	</p> 
	<ol class=files></ol> 
	</td> 
 </table>
	
</body>
<script>
//begin $(document).ready(handler)
$(function(){
$('#form1').submit(function(){
	return $('#form1').form('validate');
});}
);//end $(document).ready(handler)
</script>
</html>

